package com.allenkerr.mapper;

import com.allenkerr.model.Person;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by 小柯(Allen Kerr) on 17.6.18 23:36.
 */
public interface PersonMapper {

    @Select("select * from Person")
    public List<Person> findAll();

    @Select("select * from Person where id = #{id}")
    public Person findById(Integer id);

    @Select("select * from Person where name = #{name}")
    public Person findByName(String name);

    @Insert("insert into Person(name, age) values(#{name}, #{age})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")//接收自增主键的值
    public void saveOne(Person person);
}
